<template>
  <!--header start 个人信息-->
  <div class="my_box">
    <div class="my_header">
      <div class="my_headerTop">
        <!-- <div @click="customerSign" class="customer_sign"><span>签到</span></div> -->
        <!-- <div><img class="not_save_img" src="../../assets/img/shopMain/scanning.png"></div> -->
      </div>
      <div class="my_headerBottom">
        <div class="my_info">
          <div class="my_msg">
            <div class="user_pic" @click="pushPath('/changeAvatar')">
              <img :src="userInfo.customerHead" class="not_save_img">
            </div>
            <div class="my_nickname">
              <label class="text_hide">
                <h2>{{userInfo.customerNumber}} </h2>
              </label>
              <!-- <label for="">
                信用等级：{{userInfo.customerLevelName}}
              </label> -->
              <label for="">
                <em style="width:2em">{{$t("lang.lv")}}</em>：{{userInfo.levelName}}
              </label>
              <label for="">
                <em style="width:2em">{{$t("lang.Trname")}}</em>：{{userInfo.trueName||"--"}}
              </label>
            </div>
            <!-- <div @click="customerSign" class="customer_sign"><span>签到</span></div> -->
          </div>
        </div>
      </div>
    </div>
    <!--header end-->
    <!-- menu start -->
    <div class="home_listmenu">
      <ul class="ce_serve">
        <li @click="pushPath('/myFriend')">
          <div class="home_mleft">
            <div class="my_icon_box circle_friend_recruitment_img"></div>
            <span>{{$t("lang.membershipInformation")}}</span>
          </div>
          <i class="iconfont icon-arrow-right"></i>
        </li>
        <li @click="pushPath('/enableMenber')">
          <div class="home_mleft">
            <div class="my_icon_box home_img2"></div>
            <span>{{$t("lang.activate")}}</span>
          </div>
          <p><i class="iconfont icon-arrow-right"></i></p>
        </li>
        <li @click="pushPath('/circleFriendRecruitment')">
          <div class="home_mleft">
            <div class="my_icon_box home_img3"></div>
            <span>{{$t("lang.popularize")}}</span>
          </div>
          <i class="iconfont icon-arrow-right"></i>
        </li>
        <!-- <li @click="pushPath('/Exchangecenter')"> -->
        <li @click="Moneychanger()" :data-id="customerType">
          <div class="home_mleft">
            <div class="my_icon_box home_img4"></div>
            <span>{{$t("lang.redemptionCenter")}}</span>
          </div> 
          <i class="iconfont icon-arrow-right"></i>
        </li>
        <li @click="pushPath('/myWallt')">
          <div class="home_mleft">
            <div class="my_icon_box home_img7"></div>
            <span>{{$t("lang.seedFraction")}}</span>
          </div>
          <i class="iconfont icon-arrow-right"></i>
        </li>
        <li @click="pushPath('/myHoney')">
          <div class="home_mleft">
            <div class="my_icon_box home_img11"></div>
            <span>{{$t("lang.MySecretary")}}</span>
          </div>
          <i class="iconfont icon-arrow-right"></i>
        </li>
        <li @click="pushPath('/message')">
          <div class="home_mleft">
            <div class="my_icon_box home_img5"></div>
            <span>{{$t("lang.notices")}}</span>
          </div>
          <i class="iconfont icon-arrow-right"></i>
        </li>
        <!-- <li @click="pushPath('/entMemberList')">
          <div class="home_mleft">
            <div class="my_icon_box home_img3"></div>
            <span>{{$t("lang.activationrecord")}}</span>
          </div>
          <i class="iconfont icon-arrow-right"></i>
        </li> -->
        <li @click="pushPath('/setting')">
          <div class="home_mleft">
            <div class="my_icon_box home_img6"></div>
            <span>{{$t("lang.setting")}}</span>
          </div>
          <i class="iconfont icon-arrow-right"></i>
        </li>
        
        </ul>
    </div>
    <div style="padding-bottom:50px;"></div>
  </div>
</template>
<script>
import { MessageBox } from "mint-ui";
import { Toast,Dialog  } from "vant";
import myFooter from "@/components/footer.vue";

export default {
  name: "my",
  data() {
    return {
      userInfo: {},
      isAuth: false,
      customerType:"",
      totalWorth:"",

    };
  },
  components: {
    "my-footer": myFooter
  },
  computed: {
    msgNum() {
      return this.$store.state.msgNum;
    }
  },
  created() {},
  mounted() {
    this.$store.commit("updateSelected", 3);
    this.$store.commit("updateNeedShowFooter", true);
    this.getUserInfo();
    this.selectAccount();
  },
  methods: {
    getUserInfo() {
      this.$ajax(this.$api.getMyInfo).then(res => {
        if (res.code === 0 && res.msg) {
          this.userInfo = res.msg;
          this.customerType=res.msg.customerType;
          this.isAuth = res.msg.flagAuth == 0 ? false : true;
          localStorage.setItem("userInfo", JSON.stringify(res.msg));
          
        }
      });
    },
    Moneychanger(){
      // 兑换升级
      console.log(this.customerType);
      if(this.customerType==2){
        this.$router.push({ path: "/Exchangecenter" });
      }else if(this.customerType==1){
          Dialog.confirm({
          title: this.$t("lang.ExchangeUT"),
          message: this.$t("lang.DYAFTEC"),
          confirmButtonText:this.$t("lang.confirm"),
          cancelButtonText:this.$t("lang.cancel"),
        }).then(() => {
          // on confirm
          this.$ajax(this.$api.applyExchange,).then(res => {
            if (res.code === 0) {
              if (res.msg) {
                Toast({ message: res.msg, position: "bottom" });
                return;
              }
            } else {
              Toast({ message: res.msg, position: "bottom" });
              return;
            }
          });
        }).catch(() => {
          // on cancel
        });
      }
    },
    // POST /api/customer/selectAccount
    selectAccount(){
      this.$ajax(this.$api.selectAccount,).then(res => {
            if (res.code === 0) {
              if (res.msg) {
                this.totalWorth=res.msg.totalWorth.toFixed(4);
              }
            }
      });
    }
    
  }
};
</script>
<style>
.my_headerTop {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  line-height: 26px;
  padding: 0 10px;
}
.my_box {
  background: #f5f5f5;
}
/*header start*/
.my_box .my_header {
  background: url(../../assets/img/my/grzx_bg.png);
  padding: 40px 5% 55px 5%;
  color: #fff;
  font-size: 14px;
  background-size: 100%;
}
.my_box .my_header .my_headerTop img {
  width: 1.4rem;
  margin-right: 1rem;
}
.my_box .my_header .my_headerBottom {
  margin-top: 10px;
  position: relative;
}
.my_box .my_header .my_headerBottom .my_msg {
  display: flex;
  align-items: center;
}
.my_nickname {
  width: 80vw;
  padding-left: 10px;
  box-sizing: border-box;
  color: #E1AF56;
}
.my_nickname label {
  display: block;
  padding-left: 10px;
  font-size: 14px;
  line-height: 25px;
}
.my_nickname span {
  padding: 2px 15px;
  border-radius: 20px;
  box-shadow: 0 0 1px #eee;
  font-size: 12px;
}
.my_nickname h2 {
  color: #E1AF56;
}
.my_attention {
  position: absolute;
  top: 0;
  right: 0;
}

.my_attention p span {
  display: inline-block;
  border: 0.08rem solid #fff;
  border-radius: 0.8rem 0 0 0.8rem;
  height: 1.6rem;
  line-height: 1.6rem;
  padding: 0 0.5rem;
  font-size: 0.8rem;
  margin-left: 0.3rem;
  border-right: none;

  box-sizing: border-box;
}
.my_attention p em {
  font-size: 1.2rem;
}
.my_attention p:last-child {
  margin-top: 0.5rem;
}

/*header end*/

/*center start*/
/*center start*/
.ce_serve {
  overflow: hidden;
  background: #fff;
  border-bottom: 1px #f2f2f2 solid;
  margin-top: 0px;
}
.ce_serve li{
  height: 50px;
  display: flex;
  justify-content:space-between;
  align-items:center;
  box-sizing: border-box;
  border-bottom: 1px solid #eeeeee;
}
.ce_serve li i{
    margin-right: 12px;
  }
.home_mleft {
    display: flex;
  }
.ce_serve .my_icon_box {
  width: 30px;
  height: 30px;
  overflow: hidden;
  background-image: url(../../assets/img/my/menu_3.png);
  background-repeat: no-repeat;
  background-size: cover;
}
.circle_friend_recruitment_img {
  background-position: 4px -1px;
}
.home_img1 {
  background-position: 6px 11.5%;
}
.home_img2 {
  background-position: 5px 12%;
}
.home_img3 {
  background-position: 5px 22.5%;
}
.home_img4 {
  background-position: 6px 33.2%;
}
.home_img5 {
  background-position: 6px 44.2%;
}
.home_img6{
  background-position: 7px 55.8%;
}
.home_img7{
  background-position: 6px 66%;
}
.home_img8{
  background-position: 6px 100%;
}
.home_img11{
  background-position: 6px 77.5%;
}
.home_img10{ background-position: 4px 34%;}
.ce_serve span {
  display: block;
  font-size: 14px;
  margin:5px 0 5px 10px;
  color: #333333;
  line-height: 20px;
}
h3{font-weight: 500;}
/*center end*/
/*center end*/
/*bottom start*/
.my_bottom {
  margin-top: 5px;
  font-size: 14px;
  background: #fff;
  padding: 0 10px;
  border-top: 1px #f2f2f2 solid;
  border-bottom: 1px #f2f2f2 solid;
}
.my_bottom li{
  display: flex;
  align-items: center;
  color: #666;
  padding: 10px;
  border-bottom: 1px #f2f2f2 solid;
}
.my_bottom li:last-child{
  border-bottom:none;
}
.my_bottom i{
  flex: 1;
  display: inline-block;
  max-width: 28px;
  height: 28px;
  background-image: url(../../assets/img/home/home_icon.png);
  background-repeat: no-repeat;
  background-size: 450%;
  margin-right: 10px;
}
.my_icon_1{
  background-position: -32px -160px;
}
.my_icon_2{
  background-position: -32px -128px;
}
.my_icon_3{
  background-position: -66px -128px;
}
.my_icon_4{
  background-position: -99px -128px;
}
.my_icon_5{
  background-position: -66px -160px;
}
.my_icon_6{
  background-position: 0 -128px;
}
.my_icon_7{
  background-position: -99px -160px;
}
.my_icon_8{
   background-position: 0 -192px;
}
.my_bottom span{
  flex: 1;
}
.my_bottom em{
  max-width: 10px;
  flex: 1;
}

.user_pic {
  width: 20vw;
  height: 20vw;
  overflow: hidden;
  border-radius: 50%;
}
.user_pic img {
  width: 100%;
}
.my_integral {
  display: flex;
  text-align: center;
}
.my_integral_box {
  width: 33.33%;
  padding: 0 10px;
  box-sizing: border-box;
}
.my_integral_name {
  border: 1px #fff solid;
  border-radius: 25px;
  margin: 5px auto 10px;
  padding: 4px 0;
}
.my_autograph {
  width: 100%;
  margin: 10px 0;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.customer_sign {
  width: 20vw;
  height: 20vw;
}
.customer_sign span {
  border: 1px #fff solid;
  padding: 4px 15px;
  border-radius: 25px;
  display: block;
  text-align: center;
}
</style>
